import { request } from "@/utils/service"
import type * as Table from "./types/table"

/** 增 */
export function createTableDataApi(data: Table.CreateOrUpdateTableRequestData) {
  return request({
    url: "ticket",
    method: "post",
    data
  })
}

/** 删 */
export function deleteTableDataApi(id: string) {
  return request({
    url: `ticket/${id}`,
    method: "delete"
  })
}

/** 改 */
export function updateTableDataApi(data: Table.CreateOrUpdateTableRequestData) {
  return request({
    url: "ticket",
    method: "put",
    data
  })
}

/** 查 */
export function getTableDataApi(params: Table.TableRequestData) {
  return request<Table.TableResponseData>({
    url: "ticket",
    method: "get",
    params
  })
}

export function getAllCheciIdsApi(){
  return request<number[]>({
    url: "checi/getIds",
    method: "get"
  })
}

export function getStopsAndStartTimeAndEndTimeApi(params: {checiId: number}) {
  return request<Table.TableData2>({
    url: "route/getStopsByCheciId",
    method: "get",
    params
  })
}
